package com.css.fxfzysx.constants;


import java.util.Map;
import java.util.Optional;
import java.util.TreeMap;

public  enum  SrcEnum {
    BASICINTACT(0, "基本完好"),

    DISTROY(10, "毁坏"),

    MINORDAMAGE(1, "轻微破坏"),


    MODERATEDAMAGE(3, "中等破坏"),

    SERIOUSDAMAGE(6, "严重破坏");

    private   double state;

    private   String name;

    SrcEnum(double state, String name) {
        this.state = state;
        this.name = name;
    }


    private static final TreeMap<Double, SrcEnum> DOUBLE_SRC_ENUM_TREE_MAP = new TreeMap<>();


    static {
        for (SrcEnum srcEnum : SrcEnum.values()) {
            DOUBLE_SRC_ENUM_TREE_MAP.put(srcEnum.state, srcEnum);
        }
    }

    public static Optional<SrcEnum> getSrcEnumByIndex(double index,String type) {
        Map.Entry<Double,SrcEnum> entry = DOUBLE_SRC_ENUM_TREE_MAP.floorEntry(index);
        switch (type){
            case "框架-剪力墙结构":

                break;
            case "框架结构":
                break;
            case "剪力墙结构":
                break;
        }
        return entry ==null ? Optional.empty() : Optional.of(entry.getValue());

    }

    public double getState() {
        return this.state;
    }

    public String getName() {
        return this.name;
    }




}
